---
category: Math
created: '2021-04-10'
openGraphCover: /og/1-loc/calculate-midpoint-two-points.png
title: Calculate the midpoint between two points
updated: '2021-10-13'
---

**JavaScript version**

```js midpoint.js
const midpoint = (p1, p2) => [(p1.x + p2.x) / 2, (p1.y + p2.y) / 2];
```

**TypeScript version**

```ts midpoint.ts
interface Point {
    x: number;
    y: number;
}

const midpoint = (p1: Point, p2: Point): number[] => [(p1.x + p2.x) / 2, (p1.y + p2.y) / 2];
```

## See also

-   [Calculate the midpoint of a given range](https://phuoc.ng/collection/1-loc/calculate-the-midpoint-of-a-given-range/)
